package com.hlhj.funlike_businessqzxd.moudle;

import android.content.Context;

import com.example.mymvp.mvp.BaseModule;
import com.hlhj.funlike_businessqzxd.api.Apis;
import com.hlhj.funlike_businessqzxd.api.BaseObser;
import com.hlhj.funlike_businessqzxd.bean.TotalBean;
import com.hlhj.funlike_businessqzxd.bean.WaterListBean;
import com.lzy.okgo.model.Response;

import java.util.List;

public class CashierMoudle implements BaseModule{
    public interface getTotalMoney{
        void loadTotalMoney(TotalBean.DataBean dataBean);

        void loadWaterList(List<WaterListBean.DataBeanX.DataBean> dataBeans);
    }

    public getTotalMoney listener;

    public void setListener(getTotalMoney listener) {
        this.listener = listener;
    }

    public void LoadTotalMoney(Context context){
        Apis.INSTANCE.ShopMoney()
                .subscribe(new BaseObser<Response<TotalBean>>(context) {
                    @Override
                    public void httpSuccess(Response<TotalBean> totalBeanResponse) {
                        if (listener!=null){
                            listener.loadTotalMoney(totalBeanResponse.body().getData());
                        }
                    }
                });
    }

    public void LoadWaterList(Context context,int p){
        Apis.INSTANCE.WaterList(p)
                .subscribe(new BaseObser<Response<WaterListBean>>(context) {
                    @Override
                    public void httpSuccess(Response<WaterListBean> waterListBeanResponse) {
                        if (listener!=null){
                            listener.loadWaterList(waterListBeanResponse.body().getData().getData());
                        }
                    }
                });
    }
}
